package com.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.dao.ZhujiDao;
import com.pojo.Zhuji;
import com.util.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class ZhujiService extends ServiceImpl<ZhujiDao, Zhuji> {

    @Autowired
    private ZhujiDao zhujiDao;

    public IPage selectzhuji(int page, int limit, String name, String status) {
        Page p = new Page(page, limit);
        QueryWrapper<Zhuji> query = new QueryWrapper();

        if(StringUtil.isNotNull(name)) {
            query.and(wrapper->wrapper.like("remarks" , name).or().like("address",name).or().like("port",name).or().like("uid",name));
        }
        if(StringUtil.isNotNull(status)) {
            query.eq("status" , status) ;
        }
        IPage iPage = zhujiDao.selectPage(p, query);
        return iPage;
    }

}
